<%
# Renders the workload data for one single issue.
# Parameters:
#  * user: The user to render the data for.
#  * issue: The issue to render the data for.
#  * data: The data to render. A hash with days as keys.
#  * index: Index of the issue for this user.
%>

<%
  klass  = (index % 2 == 0) ? 'even' : 'odd'
  klass += ' overdue' if !issue.due_date.nil? && (issue.due_date < @today)
%>

<tr class="issue-workload <%= klass %>">
  <th class="issue-description" scope="row">
    <div class="tooltip"><%= link_to_issue(issue) %>
      <span class="tip"><%= render_issue_tooltip(issue) %></span>
    </div>
  </th>
  <%
    data.keys.sort.each do |day|
      dataForDay = data[day]

      klass  = 'hours'
      klass += ' active'        if  dataForDay[:active]
      klass += ' not-active'    if !dataForDay[:active]
      klass += ' holiday'       if  dataForDay[:holiday]
      klass += ' workingday'    if !dataForDay[:holiday]
      klass += ' not-estimated' if  dataForDay[:noEstimate]
      klass += ' estimated'     if !dataForDay[:noEstimate]
      klass += ' today'         if  @today === day
      klass += ' ' + ListUser::getLoadClassForHours(dataForDay[:hours])

      hoursString = (dataForDay[:hours].abs < 0.01) ? '' : sprintf("%.1f", dataForDay[:hours])
  %>
    <td class="<%= klass %>">
      <span>
        <%= hoursString %>
      </span>
    </td>
  <% end %>
</tr>